/*
============================================================================
FileName	:	XQChatRoster.h
Author		:	liyake
Website		:	http://www.liyake.com
Create Data	:	2012-03-14 16:27
Change Data	:	2012-03-14 16:27
Detail		:	just like a struct
============================================================================
*/

#ifndef _XQCHAT_ROSTER_ITEM_H_
#define _XQCHAT_ROSTER_ITEM_H_

#include <QStandardItem>
#include <QItemDelegate>
#include <QPainter>
#include "XQChatRoster.h"

using namespace XQChat;

class CXQChatRosterItem : public QObject , public QStandardItem
{
	Q_OBJECT
public:
    enum userRoles
    {
        StatusText = Qt::UserRole + 2,
        StatusType,
        PresenceType,
        BareJid,
        Avatar
    };
	
    CXQChatRosterItem(CXQChatRoster* roster);

    void setName(const QString& name);
    QString getName();
    void setBareJid(const QString& bareJid);
    void setStatusText(const QString& text);
    void setStatusType(QXmppPresence::Status::Type type);
    void setPresenceType(QXmppPresence::Type type);
    void setAvatar(const QImage& image);
    QImage getAvatar();
    QString getBareJid();
    QString getStatusText();
    QXmppPresence::Status::Type getStatusType();
    QXmppPresence::Type getPresenceType();

protected slots:
	void onHeaderIconChanged();

private:
	CXQChatRoster* m_pRoster;
};

class rosterItemDelegate : public QItemDelegate
{
public:
    rosterItemDelegate();
    QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
    void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
};

#endif // _XQCHAT_ROSTER_ITEM_H_
